package com.learn.dubbo.log.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.learn.dubbo.core.redis.core.JedisUtil;
import com.learn.dubbo.core.util.JsonUtil;
import com.learn.dubbo.entity.log.SysLog;
import com.learn.dubbo.log.ConstantObject;
import com.learn.dubbo.log.mapper.SysLogMapper;
import com.learn.dubbo.log.service.LogRemoteService;

@Service
public class LogRemoteServiceImpl implements LogRemoteService{
	
	@SuppressWarnings("unused")
	private static final Logger logger=LoggerFactory.getLogger(LogRemoteServiceImpl.class);
	
	@Autowired
	private SysLogMapper sysLogMapper;

	@Override
	public SysLog getSysLogInfo(Long id) {
		SysLog log = sysLogMapper.getSysLogById(id);		
		return log;
	}

	@Override
	public List<SysLog> getSysLogPageInfo(Map<String, Object> map) {
//		Page<String> page=PageHelper.startPage(null);
		return null;
	}

	@Override
	public int saveSysLogToDB(SysLog sysLog) {
		int result = sysLogMapper.saveSysLog(sysLog);
		return result;
	}
	
	@Override
	public int saveSysLogToRedis(SysLog sysLog) {
		JedisUtil  jedisUtil = new JedisUtil();
		String logJson = JsonUtil.writeValueAsString(sysLog);
		jedisUtil.lpush(ConstantObject.LOG_SAVE_QUENE, logJson);
		return 1;
	}

}
